const mongoose = require('mongoose')
const leaveSchema = mongoose.Schema({
    orderNo: String,
    applyType: Number,
    startTime: String,
    endTime: String,
    applyUser: {
        userId: String,
        userName: String,
        userEmail: String,
    },
    leaveTime: String,
    reasons: String,
    auditUsers: String,
    curAuditUserName: String,
    auditFlows: [{
        userId: String,
        userName: String,
        userEmail: String,
    }],
    auditLogs: [{
        userId: String,
        userName: String,
        userEmail: String,
        createTime: Date,
        remark: String,
        action: String,
    }],
    applyState: {
        type: Number,
        default: 1
    },
}, {
    timestamps: { // 使用mongoose新增的内置时间戳记录
        createdAt: 'createTime',
        updatedAt: 'updateTime'
    }
})

module.exports = mongoose.model("leave", leaveSchema, "leaves")